package Controlador;

import Modelo.Listas;
import Vista.JFrameMain;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;

public class ControladorMenuPrin implements ActionListener {

    private JFrameMain formMenuPrin;
    private Listas Lis;

    public ControladorMenuPrin() {
        /*Lis = new Listas();
        Lis.CargarRutas();
        Lis.CargarChoferes();
        Lis.CargarUnidadT();
        Lis.CargarSocio();
        Lis.CargarCooperativa();
        Lis.CargarRutaCoop();
        Lis.CargarFeriados();
        */
        formMenuPrin = new JFrameMain();
        formMenuPrin.agregarListener(this);
        formMenuPrin.setVisible(true);

    }

    // Opciones del Menu
    @Override
    public void actionPerformed(ActionEvent e) 
    {
        //---------------------------------------------
        if (e.getSource().equals(formMenuPrin.getjMenuItemChoferes())) {
            try {
                new ControladorChoferes();
            } catch (SQLException ex) {
                Logger.getLogger(ControladorMenuPrin.class.getName()).log(Level.SEVERE, null, ex);
            }
            return;
        }
        //---------------------------------------------
        if (e.getSource().equals(formMenuPrin.getjMenuItemRutas())) {
            new ControladorRutas();
            return;
        }
        //---------------------------------------------
        if (e.getSource().equals(formMenuPrin.getjMenuItemUnidadT())) {
            try {
                new ControladorUnidadT();
            } catch (SQLException ex) {
                Logger.getLogger(ControladorMenuPrin.class.getName()).log(Level.SEVERE, null, ex);
            }
            return;
        }
        //---------------------------------------------
        if (e.getSource().equals(formMenuPrin.getjMenuItemCooperativa())) 
        {
            new ControladorCooperativa();
            return;
        }
        //---------------------------------------------
        if (e.getSource().equals(formMenuPrin.getjMenuItemSocio())) {
            try {
                new ControladorSocio();
            } catch (SQLException ex) {
                Logger.getLogger(ControladorMenuPrin.class.getName()).log(Level.SEVERE, null, ex);
            }
            return;
        }
        //-----------------------
        if (e.getSource().equals(formMenuPrin.getjMenuItemAsignarViajes())) {
            new ControladorViajes();
            return;
        }
        //---------------------------------------------
        if (e.getSource().equals(formMenuPrin.getjMenuAsignarRutas())) 
        {
            try {
                new ControladorRutaCoop();
            } catch (SQLException ex) {
                Logger.getLogger(ControladorMenuPrin.class.getName()).log(Level.SEVERE, null, ex);
            }
            return;
        }
        //---------------------------------------------
        if (e.getSource().equals(formMenuPrin.getjMenuSalir())) {
            formMenuPrin.dispose();
        }
        //---------------------------------------------
        if (e.getSource().equals(formMenuPrin.getjMenuItemFeriados())) {
            new ControladorDiasFeriados();
            return;
        }
        //---------------------------------------------
        if (e.getSource().equals(formMenuPrin.getjMenuItemAsignarMultas())) {
            new ControladorMultas();
            return;
        }
        //---------------------------------------------
        if (e.getSource().equals(formMenuPrin.getjMenuIAsigVeh())) {
            try {
                new ControladorReporteAsigVehiculo();
            } catch (SQLException ex) {
                Logger.getLogger(ControladorMenuPrin.class.getName()).log(Level.SEVERE, null, ex);
            }
            return;
        }
        //---------------------------------------------  
        if (e.getSource().equals(formMenuPrin.getjMenuIAsigChof())) {
            try {
                new ControladorReporteAsigChofer();
            } catch (SQLException ex) {
                Logger.getLogger(ControladorMenuPrin.class.getName()).log(Level.SEVERE, null, ex);
            }
            return;
        }
        //--------------------------------------------- 
        if (e.getSource().equals(formMenuPrin.getjMenuIMultados())) {
            try {
                new ControladorReporteMultados();
            } catch (SQLException ex) {
                Logger.getLogger(ControladorMenuPrin.class.getName()).log(Level.SEVERE, null, ex);
            }
            return;
        }
        //---------------------------------------------  
        if (e.getSource().equals(formMenuPrin.getjMenuItemSalir())) {
            formMenuPrin.dispose();
        }
        //-----------------------
        if (e.getSource().equals(formMenuPrin.getjMenuICalendario())) 
        {
            new ControladorReporteCalenAsigVehiculo(Lis);
        }
        //-----------------------
        if (e.getSource().equals(formMenuPrin.getjMenuAcerca())) 
        {
            new ControladorAcercaD();
        }
        
    }
}
